<?php
namespace App\Domain\Examples;

use App\Model\Examples\SpotView as ModelCURD;

class SpotView {

    public function insert($newData) {
        $model = new ModelCURD();
        return $model->insert($newData);
    }

    public function update($id, $newData) {
        $model = new ModelCURD();
        return $model->update($id, $newData);
    }

    public function get($id) {
        $model = new ModelCURD();
        return $model->get($id);
    }
    public function delete($id) {
        $model = new ModelCURD();
        return $model->delete($id);
    }
    public function getSpotViewByWord($word,$sort_type_id,$page,$perpage){
        $rs = array('items' => array(), 'total' => 0);

        $model = new ModelCURD();
        $items = $model->getSpotViewByWord($word,$sort_type_id,$page,$perpage);
        $total = $model->getListTotal($word,$sort_type_id,'');

        $rs['items'] = $items;
        $rs['total'] = $total;
        $rs['page'] = $page;
        $rs['perpage'] = $perpage;
        return $rs;
    }

    public function getList($page, $perpage,$city_id) {
        $rs = array('items' => array(), 'total' => 0);

        $model = new ModelCURD();
        $items = $model->getListItems($page, $perpage,$city_id);
        $total = $model->getListTotal('','',$city_id);

        $rs['items'] = $items;
        $rs['total'] = $total;

        return $rs;
    }
}
